package com.wantup.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;

/**
 * @ClassName DisConnectEventListener
 * @Description TODO
 * @Author zhaoluowei
 * @Date 2019/6/23  20:16
 * @Version 1.0
 */
@Component
public class DisConnectEventListener implements ApplicationListener<SessionDisconnectEvent> {
    @Override
    public void onApplicationEvent(SessionDisconnectEvent sessionDisconnectEvent) {
        StompHeaderAccessor accessor = StompHeaderAccessor.wrap(sessionDisconnectEvent.getMessage());
        System.out.println("DisConnectEventListener --> 获取消息类型  "+accessor.getCommand().getMessageType());
        System.out.println("DisConnectEventListener --> session标识符  "+accessor.getSessionId());
    }
}
